package com.study;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * @Description: TODO
 * @Author: csc
 * @Date: 2024/4/24 11:59
 * @Version: 1.0
 **/
public class C {

    public static void main(String[] args) {
        try {
            URL url = new URL("https://10.10.253.2/evo-apigw/evo-oss/ba06f5b5-651f-11ee-b16c-e8611a0a8b5f/20240424/1/0412db4b-01d5-11ef-b004-e8611a0a8b5f.jpg?token=23:B6gujh8IF9iirL8qiUydXYLg9zMNU9g5"); // 替换为你的HTTPS接口URL
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET"); // 使用GET方法，也可以使用POST方法

            // 如果需要，添加请求头
             conn.setRequestProperty("Authorization", "bearer 23:AkpVUcmcxNtXE7RVgLbhM11p1bcUoNjL");

            // 发起请求
            conn.connect();

            // 检查响应状态
            if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                // 获取响应的输入流
                InputStream inputStream = conn.getInputStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
                StringBuilder response = new StringBuilder();

                String line;
                while ((line = reader.readLine()) != null) {
                    response.append(line);
                }

                reader.close();
                inputStream.close();

                // 打印响应字符串
                System.out.println(response.toString());
            } else {
                System.out.println("GET request not worked");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
